#!/usr/bin/python2.7
#
# Copyright 2011 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

'''
Created on Dec 8, 2011

@author: ibrahimelfar
'''

from django.template import Context, loader

class CommandSet:
    def __init__(self, module, command_set_type = 'application', commands = []):
        self.module = module
        self.type = command_set_type
        self.commands = commands

class Command:
    def __init__(self, name, contents):
        self.name = name 
        self.contents = contents
        
class CommandContent:
    def __init__(self, content_type):
        self.content_type = content_type

class StepCommandContent(CommandContent):
    def __init__(self, steps = []):
        CommandContent.__init__(self, 'STEPS')
        self.steps = steps

class Step:
    def __init__(self, step_type, value):
        self.step_type = step_type
        self.value = value

class KeyStep(Step):
    def __init__(self, value):
        Step.__init__(self, 'key', value)

class TextStep(Step):
    def __init__(self, value):
        Step.__init__(self, 'text', value)

def generate_command_file():
    command_sets = [
                    CommandSet('eclipse', 'application', [
                                                          Command('cmd1',
                                                                  StepCommandContent([KeyStep('ctrl+c'), TextStep('some text')])),
                                                          Command('cmd2',
                                                                  StepCommandContent(['step2.1']))]),
                    CommandSet('notepad', 'application', [Command('cmd3',
                                                                  StepCommandContent(['step3.1', 'step3.2']))]),
                    ]
    lists = dict(
             var1 = ['a', 'b'],
             var2 = ['c', 'd']
             )
    context = Context(dict(
                           command_sets = command_sets,
                           lists = lists                           
                           ))
    print loader.render_to_string('naturallyspeaking.xml', context)
    print command_sets[0].commands[0].contents.steps[0].step_type
